package com.kitchen.music.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 定位项目图片地址
 */
@Configuration
public class FilePicConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/img/pic/**").addResourceLocations(
                "file:" +System.getProperty("user.dir") + System.getProperty("file.separator")+ "img"+ System.getProperty("file.separator")+"toys_image"+
                         System.getProperty("file.separator")
                        );
        //前端用户头像地址
        registry.addResourceHandler("/avatorImages/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"avatorImages"+System.getProperty("file.separator")
        );
        //用户头像默认地址
        registry.addResourceHandler("/img/pic**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"img"+System.getProperty("file.separator")+"pic"+
                        System.getProperty("file.separator")
        );

        //商品图片默认地址
        registry.addResourceHandler("goodsImage/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"goodsImage"+System.getProperty("file.separator")
        );
        //订单图片默认地址
        registry.addResourceHandler("orderImg/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")+"img"+System.getProperty("file.separator")+"orderImg"+
                        System.getProperty("file.separator")
        );
    }
}
